// 导入express
const express=require('express');
// 导入webpack
const webpack=require('webpack');
// 导入wepack.dev.config.js
const config=require('./webpack.dev.config');
//  导入webpack-dev-middleware
const webpackDevMiddleware=require('webpack-dev-middleware');
// 创建服务器
const app=express();
const compiler=webpack(config);

// 注册中间件
app.use(webpackDevMiddleware(compiler,{
    publicPath:config.output.publicPath
}));

// 启动服务器
app.listen(3000,()=>{
    console.log('http server running at http://localhost:3000');
});

